﻿/*
 * ©2009-2010 XELF
 * http://xelf.info
 */

using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;

namespace XELF.Framework {

	public struct EffectPassEnumerator : IEnumerator<EffectPass> {
		EffectPassCollection passes;
		int index;
		public EffectPassEnumerator(EffectPassCollection passes) {
			this.passes = passes; index = -1;
		}
		public EffectPassEnumerator GetEnumerator() { return this; }
		public EffectPass Current { get { return passes[index]; } }
		public void Dispose() { }
		object System.Collections.IEnumerator.Current { get { return passes[index]; } }
		public bool MoveNext() {
			if (index >= passes.Count - 1) return false;
			index++; return true;
		}
		public void Reset() { index = -1; }
	}

	public static partial class Helper {
		public static EffectPassEnumerator Passes(this EffectTechnique technique) {
			return new EffectPassEnumerator(technique.Passes);
		}
		public static EffectPassEnumerator ForEach(this EffectPassCollection passes) {
			return new EffectPassEnumerator(passes);
		}
	}
}
